const mongoose=require('mongoose')
const { Schema,model } =mongoose

const userSchema=new Schema({
    __v:{type:Number,select:false},
    name:{//用户名
        type:String,
        required:true
    },
    password:{//密码
        type:String,
        required:true,
        select:false,//请求不会返回password
    },
    avatar_url:{//头像
        type:String,
    },
    gender:{//性别
        type:String,
        enum:['male','female'],
        default:'male',
        required:true
    },
    headline:{//一句话简介
        type:String,
    },
    locations:{//居住地
        type:[{ type:Schema.Types.ObjectId,ref:'Topic'}],
        select:false,
    },
    business:{//所在行业
        type:Schema.Types.ObjectId,ref:'Topic',
        select:false,
    },
    employments:{//职业经历
        type:[
            {
                company:{//公司
                    type:Schema.Types.ObjectId,ref:'Topic',
                },
                job:{//职位
                    type:String,
                },
            }
        ],
        select:false,
    },
    educations:{//教育经历
        type:[
            {
                school:{//学校
                    type:Schema.Types.ObjectId,ref:'Topic',
                },
                major:{//专业
                    type:Schema.Types.ObjectId,ref:'Topic',
                },
                diploma:{//学历
                    type:Number,
                    enum:[1,2,3,4,5],
                },
                emtrance_year:{//入学年份
                    type:Number,
                },
                graduation_year:{//毕业年份
                    type:Number,
                }
            }
        ],
        select:false,
    },
    following:{
        type:[{ type:Schema.Types.ObjectId,ref:'User'}],
        select:false
    },
    followingTopics:{
        type:[{type:Schema.Types.ObjectId,ref:"Topic"}],
        select:false,
    }
})

module.exports=model('User',userSchema)
